﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tookit.Mvvm.Navigation.Message;
using Tookit.Mvvm.Navigation.Models;
using Tookit.Mvvm.Navigation.Serves;
using Tookit.Mvvm.Navigation.Views;

namespace Tookit.Mvvm.Navigation.ViewModels
{
    public partial class MainWindowViewModel : ObservableObject
    {
        [ObservableProperty]
        object m_body;

        private StudentView _studentView;
        private TeacherView _teacherView;
        private ParentsView _parentesView;
        public UserSession m_User { get; }
        public MainWindowViewModel(StudentView studentView, TeacherView teacherView, ParentsView parentesView,UserSession userSession)
        {
            _studentView = studentView;
            _teacherView = teacherView;
            _parentesView = parentesView;
            m_User = userSession;
            

        }

        

        [RelayCommand]
        void Open(string obj)
        {
            switch (obj)
            {
                case "StudentView":
                    Body = _studentView;
                    break;
                case "TeacherView":
                    Body = _teacherView;
                    break;
                case "ParentsView":
                    Body = _parentesView;
                    break;
            }
        }

        [RelayCommand]
        void Exit()
        {
            WeakReferenceMessenger.Default.Send(new LoginOutMessage(m_User.CurrentUser));
        }
    }
}
